package liumengbaio.lolzhangyoubao.Activity.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.squareup.picasso.Picasso;

import de.hdodenhof.circleimageview.CircleImageView;
import liumengbaio.lolzhangyoubao.Activity.InFo.RealShowItem;
import liumengbaio.lolzhangyoubao.R;

/**
 * Created by lanouhn on 16/9/13.
 */
public class RealShowAdapter extends BaseAdapter {
    private RealShowItem lists;
    private Context mContext;

    public RealShowAdapter(Context mContext, RealShowItem lists) {
        this.lists = lists;
        this.mContext = mContext;
    }

    @Override
    public int getCount() {
        return lists.getData().size();
    }

    @Override
    public Object getItem(int position) {
        return lists.getData().get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (holder == null) {
            holder=new ViewHolder();
            convertView= LayoutInflater.from(mContext).inflate(R.layout.item_real_show,null);
            holder.tv_nicker_name= (TextView) convertView.findViewById(R.id.tv_nicker_name);
            holder.tv_coment= (TextView) convertView.findViewById(R.id.tv_coment_item);
            holder.tv_lol_name= (TextView) convertView.findViewById(R.id.tv_lol_name);
            holder.tv_good= (TextView) convertView.findViewById(R.id.tv_good);
            holder.tv_time= (TextView) convertView.findViewById(R.id.tv_time);
            holder.self_say= (TextView) convertView.findViewById(R.id.self_say);
            holder.circleImageView= (CircleImageView) convertView.findViewById(R.id.head_icon);
            holder.iv_icon_item= (ImageView) convertView.findViewById(R.id.iv_icon_item);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        Picasso.with(mContext).load(lists.getData().get(position).getAvatar()).into(holder.circleImageView);
        Picasso.with(mContext).load(lists.getData().get(position).getPic_url()).into(holder.iv_icon_item);
        holder.tv_nicker_name.setText(lists.getData().get(position).getNickname());
        holder.tv_lol_name.setText("召唤师:("+lists.getData().get(position).getArea()+")"+lists.getData().get(position).getSummoner());
        holder.self_say.setText(lists.getData().get(position).getDesc());
        holder.tv_time.setText(lists.getData().get(position).getCreated());
        holder.tv_good.setText(lists.getData().get(position).getGood());
        holder.tv_coment.setText(lists.getData().get(position).getComment());
        return convertView;
    }

    public class ViewHolder {
        private CircleImageView circleImageView;
        private ImageView iv_icon_item;
        private TextView tv_nicker_name, tv_lol_name, tv_time, self_say, tv_good, tv_coment;

    }
}
